#include<iostream>
using namespace std;
typedef long long ll;

//int main()
//{
//	ll n, q, l, r;
//	cin >> n >> q;
//	ll* arr = new ll[n + 1];
//	ll* dp = new ll[n + 1];
//	ll sum = 0;
//	dp[0] = 0;
//	for (ll i = 1; i <= n; ++i)
//	{
//		cin >> arr[i];
//		sum += arr[i];
//		dp[i] = sum;
//	}
//	while (q--)
//	{
//		cin >> l >> r;
//		cout << dp[r] - dp[l-1] << endl;
//	}
//	return 0;
// }

#include<vector>

int main()
{
	ll n, m, q, x1, x2, y1, y2;
	cin >> n >> m >> q;
	vector<vector<ll>>arr(n + 1, vector<ll>(m + 1, 0));
	vector<vector<ll>>dp(n + 1, vector<ll>(m + 1, 0));
	for (ll i = 1; i <= n; ++i)
	{
		for (ll j = 1; j <= m; ++j)
		{
			cin >> arr[i][j];
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + arr[i][j] - dp[i - 1][j - 1];
		}
	}
	while (q--)
	{
		cin >> x1 >> y1 >> x2 >> y2;
		cout << dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1] << endl;
	}
	return 0;
}